package com.zx.cashiersystem.utils;

import android.app.ProgressDialog;
import android.content.Context;

import com.loopj.android.http.RequestParams;
import com.zx.cashiersystem.mvp.model.OnResultListener;

/**
 * Created by Administrator on 2017/1/20.
 */

public class PayUtil {
    private Context context;

    public PayUtil(Context context) {
        this.context = context;
    }
    /**
     * 支付宝条码支付
     * @param out_trade_no 交易订单号
     * @param total_amount 订单总金额
     * @param subject      订单标题
     * @param body          订单描述
     */

    public static void aliQrPay(int requestCode, Context context, String out_trade_no, String total_amount, String subject, String body, OnResultListener listener, ProgressDialog progressDialog) {
        RequestParams params = new RequestParams();
        params.put("out_trade_no", out_trade_no);
        params.put("total_amount", total_amount);
        params.put("subject", subject);
        params.put("body", body);
        HttpUtils.post(context, Contants.ALIPAY_QRPAY, params, requestCode, listener, progressDialog);
    }

    /**
     * 支付宝条码支付
     * @param auth_code    支付授权码
     * @param out_trade_no 商户订单号,64个字符以内、可包含字母、数字、下划线；需保证在商户端不重复
     * @param subject      订单标题
     * @param total_amount 订单总金额
     */

   public static void aliPayFacePay(int requestCode, Context context, String auth_code, String out_trade_no,
                                    String total_amount, String subject, OnResultListener listener, ProgressDialog progressDialog) {
        RequestParams params = new RequestParams();
        params.put("auth_code", auth_code);
        params.put("out_trade_no", out_trade_no);
        params.put("total_amount", total_amount);
        params.put("subject", subject);
        HttpUtils.post(context, Contants.ALIPAY_FACEPAY, params, requestCode, listener, progressDialog);
    }



    /**
     *微信刷卡支付
     * @param requestCode
     * @param context
     * @param auth_code 支付授权码
     * @param out_trade_no 交易订单号
     * @param total_fee 订单总金额
     * @param body 订单描述
     * @param listener
     * @param progressDialog
     */
    public static void wxPay(int requestCode, Context context, String auth_code, String out_trade_no,
                                     String total_fee, String body, OnResultListener listener, ProgressDialog progressDialog) {
        RequestParams params = new RequestParams();
        params.put("auth_code", auth_code);
        params.put("out_trade_no", out_trade_no);
        params.put("total_fee", total_fee);
        params.put("body", body);
        HttpUtils.post(context, Contants.WXPAY, params, requestCode, listener, progressDialog);
    }

    /**
     *  微信 扫码支付
     * @param requestCode
     * @param context
     * @param body  商品描述
     * @param out_trade_no 订单号
     * @param oattach 附加参数
     * @param total_fee 订单总金额
     * @param listener
     * @param progressDialog
     */


    public static void wxQrPay(int requestCode, Context context, String body, String out_trade_no,
                                     String oattach, String total_fee, OnResultListener listener, ProgressDialog progressDialog) {
        RequestParams params = new RequestParams();
        params.put("body", body);
        params.put("out_trade_no", out_trade_no);
        params.put("oattach", oattach);
        params.put("total_fee", total_fee);
        HttpUtils.post(context, Contants.WXQRPAY, params, requestCode, listener, progressDialog);
    }

}
